********************************************************************************************************************************
***   Replication file for:                                                                                                  ***
***   Berbee, P., Braun, S. T. and Franke, R. (2024). Reversing Fortunes of German Regions, 1926-2019. JoEG.			     ***
***   							                                                                                             ***
***   SCRIPT: 	_x5a_preparation_instrument.do																				 ***	
***   PURPOSE: 	Reads in data on instrumental variable and land access 													 	 ***
********************************************************************************************************************************

* Preamble (unnecessary when executing run.do)
run "$reversing/scripts/programs/_config.do"

************
* Code begins
************

*** Import data

** Baseline version with cost vectors according to Bairoch & Daudin

* Transportation costs according to Bairoch, 1990
import excel "$reversing/data/Labor_market_1966_Saar_IV_data_Bairoch_1990.xlsx", firstrow clear 

drop A
rename Sheet1__La labor_market_id

rename Bairoch_1990_Coal coal_access1_bairoch
rename Bairoch_1990_Coal_sq coal_access2_bairoch
rename Bairoch_1990_Carb carb_access1_bairoch
rename Bairoch_1990_LAND land_access1_bairoch 
rename Bairoch_1990_LAND_sq land_access2_bairoch 
rename Bairoch_1990_Coal_PWA coal_access1_bairoch_PWA1
rename Bairoch_1990_Coal_combined coal_access1_bairoch_PWA2

label var coal_access1_bairoch "Coal area (sqm) weighted by Bairoch transport costs"
label var coal_access2_bairoch "Coal area (sqm) weighted by Bairoch transport costs squared"
label var carb_access1_bairoch "Carboniferous strata area (sqm) weighted by Bairoch transport costs"
label var land_access1_bairoch "Land access weighted by Bairoch transport costs"
label var land_access2_bairoch "Land access weighted by Bairoch transport costs squared"
label var coal_access1_bairoch_PWA1 "Coal area (sqm) weighted by Bairoch transport costs, based on PWA 1967"
label var coal_access1_bairoch_PWA2 "Coal area (sqm) weighted by Bairoch transport costs, based on PWA 1967 and FR2020"

drop Bairoch_1990_Carb_sq Bairoch_1990_Coal_PWA_sq Bairoch_1990_Coal_combined_sq

save "$reversing/processed/intermediate/iv_bairoch.dta", replace 

* Transportation costs according to Daudin, 2010
import excel "$reversing/data/Labor_market_1966_Saar_IV_data_Daudin_2010.xlsx", firstrow clear 

drop A
rename Sheet1__La labor_market_id

rename Daudin_2010_Coal coal_access1_daudin
rename Daudin_2010_Coal_sq coal_access2_daudin
rename Daudin_2010_Carb carb_access1_daudin
rename Daudin_2010_LAND land_access1_daudin 
rename Daudin_2010_LAND_sq land_access2_daudin
rename Daudin_2010_Coal_PWA coal_access1_daudin_PWA1
rename Daudin_2010_Coal_combined coal_access1_daudin_PWA2 

label var coal_access1_daudin "Coal area (sqm) weighted by Daudin transport costs"
label var coal_access2_daudin "Coal area (sqm) weighted by Daudin transport costs squared"
label var carb_access1_daudin "Carboniferous strata area (sqm) weighted by Daudin transport costs"
label var land_access1_daudin "Land access weighted by Daudin transport costs"
label var land_access2_daudin "Land access weighted by Daudin transport costs squared"
label var coal_access1_daudin_PWA1 "Coal area (sqm) weighted by Daudin transport costs, based on PWA 1967"
label var coal_access1_daudin_PWA2 "Coal area (sqm) weighted by Daudin transport costs, based on PWA 1967 and FR2020"

drop Daudin_2010_Carb_sq Daudin_2010_Coal_PWA_sq Daudin_2010_Coal_combined_sq

save "$reversing/processed/intermediate/iv_daudin.dta", replace 

** Robustness check with larger rivers only

import excel "$reversing/data/Labor_market_1966_Saar_IV_data_rivers20x2_Daudin_2010.xlsx", firstrow clear 

drop A
rename Sheet1__La labor_market_id

rename Daudin_2010_Coal coal_access1_lrivers_daudin
rename Daudin_2010_LAND land_access1_lrivers_daudin 

label var coal_access1_lrivers_daudin "Coal area (sqm) weighted by Daudin transport costs, larger rivers only"
label var land_access1_lrivers_daudin "Land access weighted by Daudin transport costs, larger rivers only"

drop Daudin_2010_*

save "$reversing/processed/intermediate/iv_daudin_lrivers.dta", replace 

** Robustness check with simple log distance

import excel "$reversing/data/Labor_Market_1966_Saar_IV_data_Log.xlsx", firstrow clear

drop A
rename Sheet1__La labor_market_id

rename IV_Log_Coal coal_access_logdist
rename IV_Log_Land land_access_logdist

label var coal_access_logdist "Coal area (sqm) weighted by log distance"
label var land_access_logdist "Land access weighted by log distance"

drop IV*

save "$reversing/processed/intermediate/iv_logdist.dta", replace 




*** EOF




